<!--报价确认-->
<template>
  <div class="confirm-container">
    <!--头部标题-->
    <!-- <el-form class="form-header" ref="form" :model="form" label-width="100px">
      <el-form-item label="项目名称" prop="extractItem">
        <el-input
          class="commonWidth"
          size="small"
          placeholder="请输入项目名称"
          v-model="queryParams.extractItem"
          @keyup.enter.native="handleQuery"
        >
        </el-input>
      </el-form-item>
      <el-form-item label="抽取人单位" prop="createBy">
        <el-select
          v-model="form.createBy"
          placeholder="请选择抽取人单位"
          clearable
          size="small"
          style="width: 100%"
          @change="UnitTypeChangepenson"
        >
          <el-option
            v-for="type in unitTypeponsonOptions"
            :key="type.userId"
            :label="type.nickName"
            :value="type.userId"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="抽取库" prop="randomUnittypeId">
        <el-select
          class="commonWidth"
          v-model="form.randomUnittypeId"
          placeholder="请选择单位库"
        >
          <el-option
            v-for="item in form.extractData"
            :key="item.unittypeId"
            :label="item.unittypeName"
            :value="item.unittypeId"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item class="btns">
        <el-button
          class="search-btn"
          icon="el-icon-search"
          type="primary"
          size="mini"
          @click="loadExtractList"
          >搜索</el-button
        >
        <el-button class="el-icon-refresh" size="mini" @click="reset">重置</el-button>
      </el-form-item>
    </el-form> -->
    <!--表格内容-->
    <el-table
      v-loading="tableLoading"
      :data="articleList"
      @current-change="currentRowChange"
      style="width: 100%"
    >
      <el-table-column type="selection" width="55"></el-table-column>
      <el-table-column
        prop="extractItem"
        align="left"
        label="项目名称"
      ></el-table-column>
      <!-- <el-table-column label="建设地址" align="left" prop="extractAddress" /> -->
      <el-table-column
        prop="extractCharge"
        align="left"
        label="经办人"
        :sortable="true"
      ></el-table-column>
      <el-table-column
        prop="tenderStartTime"
        align="left"
        label="抽取时间"
        :sortable="true"
      ></el-table-column>
      <el-table-column
        label="抽取人单位"
        align="left"
        prop="createBy"
        width="250"
      />
      <el-table-column prop="extractPrice" label="工程费用（万元）">
        <template slot-scope="scope">
          <div :style="{ textAlign: 'right', paddingRight: '65%' }">
            {{ scope.row.extractPrice }}
          </div>
        </template>
      </el-table-column>
      <el-table-column
        label="中介机构服务费（万元）"
        align="left"
        prop="maxPrice"
      />
      <el-table-column
        prop="unitTypeName"
        label="抽取库"
        width="200"
      ></el-table-column>
      <el-table-column prop="extractApproveStatus" label="审批状态">
        <template slot-scope="scope">
          <div>{{ scope.row.extractApproveStatus | formatStatus }}</div>
        </template>
      </el-table-column>
      <el-table-column prop="address" align="center" label="操作" width="350">
        <template slot-scope="scope">
          <el-button size="mini" type="text" @click="goDialog(scope.row)"
            >中标确认</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-back"
            v-hasPermi="['unit:extract:edit']"
            v-if="
              scope.row.extractApproveStatus == 7 ||
              scope.row.extractApproveStatus == 6
            "
            @click="reback(scope.row)"
            >退回抽签</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-printer"
            @click="handlePrint(scope.row)"
            >打印抽取表</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-printer"
            @click="handlePrints(scope.row)"
            >打印比选表</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <!--分页-->
    <div class="pagination">
      <el-pagination
        :current-page.sync="currentPage"
        :page-sizes="pageSizes"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="totalSize"
        @current-change="currentChange"
        @size-change="handleSizeChange"
        :disabled="isPaginationDisabled"
      />
    </div>
    <!--报价确认弹窗-->
    <el-dialog
      title="中标确认"
      :visible.sync="dialogVisible"
      width="60%"
      @close="CloseClean"
    >
      <quotationConfirm
        class="tableComponent"
        :quotationConfirm="quotationConfirm"
      />
      <quotationConfirm class="tableComponent" :quotationConfirm="price" />
      <!--简易表格-->
      <!--			<simpleTable v-show="companyInfo.length > 0" :simpleTableData="simpleTableData"></simpleTable>-->

      <template>
        <el-table :data="companyInfo" border style="width: 100%">
          <el-table-column prop="randomUnitName" label="单位名称" width="">
          </el-table-column>
          <el-table-column
            prop="name"
            label="报价情况（元）"
            align="center"
            width=""
          >
            <template slot-scope="scope">
              <input
                class="price-input"
                v-model="scope.row.bidamount"
                placeholder="请输入报价"
                type="number"
                required
              />
            </template>
          </el-table-column>
          <!-- <el-table-column prop="address" label="操作" align="center">
            <template slot-scope="scope">
              <el-button type="text" @click="applyDeduct(scope.row)">申请扣分</el-button>
            </template>
          </el-table-column> -->
        </el-table>
      </template>
      <div class="notify">
        *报价填写说明：按实际投标报价填写，单位为（元）。折扣比率报价时，用小数表示（如：65%填写为0.65）。
      </div>
      <div class="outbid-info-wrap">
        <div class="select-company" v-if="companyInfo.length > 0">
          <el-form>
            <el-form-item label="确认中标单位：">
              <el-select
                clearable
                v-model="randomUnitId"
                placeholder="请确认中标单位"
                style="width: 400px"
              >
                <el-option
                  v-for="(item, index) in companyInfo"
                  :key="index"
                  :label="item.randomUnitName"
                  :value="item.randomId"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-form>
        </div>
        <!--        <div class="upload-wrap">
          <div class="upload">
            <label>中标文本上传：</label>
            <el-upload
              class="upload-demo other"
              :disabled="uploadDisabled"
              :accept="acceptType"
              ref="uploadFile"
              action=""
              :show-file-list="false"
              :http-request="uploadFile"
            >
              <el-button size="small" type="primary">点击上传</el-button>
              <div slot="tip" class="el-upload__tip">
                请上传bmp，gif，jpg，jpeg，png文件，且不超过10MB
              </div>
            </el-upload>
          </div>
          <div class="image-wrap" v-if="imgUrl.length > 0">
            <div class="uploadimg-wrap" v-for="(item,index) in imgUrl" :key="index">
              <el-image
                style="width: 100px; height: 100px"
                :src="item"
                fit="cover"
                :preview-src-list="imgUrl"
                :z-index="3000"
              >
              </el-image>
              <i class="icon el-icon-error" @click="removeImg(index)"></i>
            </div>
          </div>
        </div>-->
      </div>
      <div class="deduction-reason-wrap">
        <label>备注：</label>
        <textarea
          class="remain"
          v-model="remark"
          cols="30"
          rows="10"
        ></textarea>
      </div>
      <span slot="footer" class="dialog-footer">
        <!-- <el-button type="primary" @click="offerConfirmation" :disabled="saveBtnDisabled">保存</el-button> -->
        <el-button type="primary" @click="randomCompanyConfirm">确认</el-button>
        <el-button @click="closeDialog">取消</el-button>
      </span>
    </el-dialog>
    <!--上传报价弹窗-->

    <PrintTable
      :form="currentRow"
      :printVisible.sync="printVisible"
      :items="companyInfo"
    />
    <!-- 比选表 -->
    <PrintTableS
      :form="currentRow"
      :comparisonVisible.sync="comparisonVisible"
      :items="companyInfo"
    />
    
  </div>
</template>

<script>
import quotationConfirm from "@/common/operation/quotationConfirm";
import simpleTable from "@/common/operation/simpleTable";
import { delRandom } from "@/api/unit/random";
import { listUser } from "@/api/system/user";
import service from "../../components/utils/request.js";
import {
  getExtractOption,
  getExtractList,
  getExtractArticle,
  updateExtract,
  randomSelect,
  Department,
  winningUnitConfirm,
  deductMarks,
  approvalConfirm,
  getMakeSureList,
  getScore,
} from "@/api/unit/extract.js";
import PrintTable from "./components/print.vue";
import PrintTableS from "./components/comparisonp.vue";

export default {
  name: "makesure",
  components: {
    quotationConfirm,
    simpleTable,
    PrintTable,
    PrintTableS,
  },
  data() {
    return {
      dialogVisible: false, //是否显示弹窗
      uploadDialogVisible: false, // 是否显示上传报价弹出层
      tableLoading: false, //表格是否处于loading状态
      isPaginationDisabled: false, // 分页是否处于禁用状态
      saveBtnDisabled: false, //保存按钮禁用
      commentDialogVisible: false, // 是否打开项目评价弹窗
      //禁用上传按钮
      uploadDisabled: false,
      currentPage: 1,
      // 传给quotationConfirm的数据
      quotationConfirm: [],
      // 传给quotationConfirm的数据
      price: [],
      //抽取人单位字典
      unitTypeponsonOptions: [],
      form: {
        randomId: null,
        extractItem: "",
        extractUser: "",
        randomUnittypeId: "",
        extractData: [], //抽取库数据
        extractId: "",
        extractApproveStatus: "",
        ProjectAmount: "",
        createBy: "",
      },
      //  提交给后台的数据
      saveData: {
        fileUrl: [],
        endDate: "", // 选择日期
        deductReason: "", // 扣分原因
        radioList: [],
      },
      printVisible: false,
      comparisonVisible: false,//比选表
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        extractItem: null,
        extractUser: null,
        extractAddress: null,
        extractPrice: null,
        extractApproveStatus: null,
        maxPrice: null,
        randomUnittypeId: null,
        userId: null,
      },
      articleList: [], //表格列表
      pageSize: 10, //分页大小
      totalSize: 0, // 数据总条数
      pageSizes: [10, 20, 30, 50],
      pageNum: 1, // 传给后台的数据页码
      // 传给simpleTable的数据
      companyInfo: [],
      currentObj: [],
      simpleTableData: {
        title: ["单位名称", "状态", "操作"], //使用方传， 组件第一个li里面的div的循环数据
        list: [],
      },
      // 上传报价参数
      quotedPrice: {
        extractId: null,
        randomId: "",
        bidamount: "",
      },
      ruleForm: {
        extractUser: "",
        extractPlace: "",
        quoteLimitTime: "",
      },
      // 上传报价弹出层文件
      fileList: [],
      // 上传文件的图片地址
      imgUrl: [],
      // 接受的文件类型
      acceptType: "bmp,gif,jpg,jpeg,png",
      // 图片类型
      imageType: "bmp,gif,jpg,jpeg,png",
      currentRow: {},
      // 中标单位
      randomUnitId: "",
      currentDialogRow: {},
      remark: "",
    };
  },

  created() {
    this.loadExtractOption();
    this.loadExtractList();
    listUser().then((response) => {
      this.unitTypeponsonOptions = response.rows;
    });
  },
  methods: {
    //抽取人单位
    UnitTypeChangepenson(value) {
      listUser().then((response) => {
        for (var o = 0; o < response.rows.length; o++) {
          if (value == response.rows[o].userId) {
            this.queryParams.createBy = response.rows[o].nickName;
          }
        }
      });
    },
    // 改变页码显示不同的数据
    currentChange(page) {
      this.queryParams.pageNum = page;
      this.loadExtractList(this.pageNum);
    },
    //每页显示的数据条数改变
    handleSizeChange(val) {
      this.queryParams.pageSize = val;
      this.currentPage = 1;
      this.queryParams.pageNum = 1;
      this.loadExtractList();
    },
    // 点击重置
    reset() {
      this.queryParams.extractItem = null;
      this.form.extractUser = null;
      this.form.randomUnittypeId = null;
      if (this.form.createBy != null) {
        this.form.createBy = null;
      }
      this.queryParams.createBy = null;
      this.loadExtractList();
      this.form.extractId = "";
      this.form.extractApproveStatus = "";
      this.form.ProjectAmount = "";
    },
    // 报价确认保存
    offerConfirmation() {
      this.$confirm("确认保存吗？")
        .then(() => {
          this.saveConfirm();
        })
        .catch(() => {});
    },
    async saveConfirm() {
      try {
        const res = await updateExtract({
          extractId: this.currentRow.extractId,
          extractApproveStatus: 7,
        });
        // console.log(res)
        const res1 = await randomSelect({
          extractId: this.currentRow.extractId,
        });
        if (res1.code === 200) {
          this.saveBtnDisabled = true;
          this.dialogVisible = false;
        } else {
          this.$message.error("请上传报价");
        }
      } catch (e) {}
    },
    // 点击报价确认弹出层
    goDialog(row) {
      this.currentDialogRow = row;
      this.dialogVisible = true;
      setTimeout(() => {
        if (this.companyInfo.length === 0) {
          this.saveBtnDisabled = true;
        } else {
          this.saveBtnDisabled = false;
        }
      }, 200);
    },
    removeImg(index) {
      this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.imgUrl.splice(index, 1);
          this.extractSignUrl = this.imgUrl;
          this.$message({
            type: "success",
            message: "删除成功!",
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
    // 关闭上传报价弹窗
    uploadDialogClose() {
      this.quotedPrice.bidamount = "";
      this.quotedPrice.randomQuoteTable = [];
      this.fileList = [];
      this.imgUrl = [];
    },
    CloseClean() {
      this.simpleTableData.list = [];
      this.randomUnitId = "";
      this.loadExtractList();
    },
    // 获取抽取库数据
    async loadExtractOption() {
      const res = await getExtractOption();
      try {
        if (res.code === 200) {
          this.form.extractData = res.rows.map((item) => {
            return item;
          });
        } else {
          this.$message.error(res.msg);
        }
      } catch (e) {
        this.$message.error(e);
      }
    },
    //获取表格列表数据
    async loadExtractList() {
      await Department().then((response) => {
        this.form.userId = response.data.userId;
      });
      this.tableLoading = true;
      this.isPaginationDisabled = true;
      try {
        this.queryParams.extractApproveStatus = "6";
        this.queryParams.randomUnittypeId = this.form.randomUnittypeId;
        const res = await getMakeSureList(this.queryParams);
        if (res.code === 200) {
          const result = res.rows;
          for (var i = 0; i < result.length; i++) {
            let obj = result[i];
            for (const j in obj) {
              if (obj[j] === null) {
                // console.log(3333,obj[j])
                obj[j] = "";
              } else {
                // console.log(2222,obj[j])
                obj[j] = obj[j];
              }
            }
          }
          this.articleList = result;
          this.totalSize = res.total;
        }
      } catch (e) {
        this.$message.error(e);
      } finally {
        this.tableLoading = false;
        this.isPaginationDisabled = false;
      }
    },
    // 获取单位信息
    async loadExtractArticle() {
      let that = this;
      const res = await getExtractArticle({
        randomBan: 2,
        extractId: this.currentRow.extractId,
      });
      this.companyInfo = res.rows;
      this.companyInfo.forEach((item) => {
        // console.log(item)
        item.fillPrice = "";
        this.simpleTableData.list.push([
          item.randomUnitName,
          this.handleRandomBan(item.randomBan),
          {
            //对象
            handleTile: "确认",
            deductMark: "扣分",
            org: item,
            callBack: (currentRow, index) => {
              // console.log(currentRow,index)
              this.currentObj = currentRow;
              this.quotedPrice.randomId =
                currentRow[currentRow.length - 1].org.randomId;
              this.uploadDialogVisible = true;
            },
            deductMarkCallBack(currentRow, index) {
              that
                .$confirm("确认进行扣分操作吗?", "提示", {
                  confirmButtonText: "确定",
                  cancelButtonText: "取消",
                  type: "warning",
                })
                .then(() => {
                  // console.log(currentRow, index)
                  that.deductPoints(currentRow);
                })
                .catch(() => {
                  that.$message({
                    type: "info",
                    message: "已取消扣分",
                  });
                });
            },
          },
        ]);
      });
    },
    // 申请扣分
    applyDeduct(currentRow) {
      this.$confirm("确认进行扣分操作吗?本次将扣除单位“2”分", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          // console.log(currentRow, index)
          this.deductPoints(currentRow);
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消扣分",
          });
        });
    },
    async deductPoints(currentRow) {
      const params = {};
      params.extractId = this.currentDialogRow.extractId;
      params.extractItem = this.currentDialogRow.extractItem;
      params.unitId = currentRow.randomUnitId;
      params.unitName = currentRow.randomUnitName;
      params.ruleId = "4";
      params.whetherDeduct = "0";
      const res = await deductMarks(params);
      if (res.code === 200) {
        this.$message.success(res.msg);
      } else {
        this.$message.error(res.msg);
      }
    },
    // 移除图片之前
    beforeRemove(file, fileList) {
      return this.$confirm(`确定移除 ${file.name}？`);
    },
    // 移除图片
    handleRemove(file, fileList) {
      // console.log(fileList);
      const index = this.fileList.findIndex((item) => item.uid === file.uid);
      // console.log(index)
      const i = this.fileList.find((item) => item === file.url);
      this.fileList.splice(index, 1);
      this.imgUrl.splice(i, 1);
      this.quotedPrice.randomQuoteTable = this.fileList.map((item) => item.url);
    },
    // 获取单位名称等数据
    async loadExtractArticl(row, print,text) {
      //  调接口，将项目id currentRow.extractId传给后台，获取当前行的评分数据
      // console.log(row.extractId||this.ids);
      getScore().then((res) => {
        this.saveData.radioList = res.rows;
        this.saveData.radioList.forEach((item) => {
          if (item.whetherDeduct === null) {
            item.whetherDeduct = "0";
          }
        });
      });
      const extractId = row.extractId || this.ids;
      const res = await getExtractArticle({ randomBan: 2, extractId });
      // console.log(res.rows);
      if (text!=1) this.printVisible = true;
      else this.commentDialogVisible = true, this.comparisonVisible=true;
      const companyInfo = res.rows;
      for (var i = 0; i < companyInfo.length; i++) {
        const obj = companyInfo[i];
        for (const j in obj) {
          if (obj[j] === null) {
            obj[j] = "";
          } else {
            obj[j] = obj[j];
          }
        }
      }
      this.companyInfo = companyInfo;
      
      companyInfo.forEach((item) => {
        this.simpleTableData.list.push([item.randomUnitName, item.bidamount]);
        for (var i = 0; i < this.simpleTableData.list.length; i++) {
          if (i >= 1) {
            this.simpleTableData.list.splice(0, 1);
          }
        }
      });
    },

    // onExceed文件上传个数限制
    onExceed() {
      this.$message.error("最多只能上传三个文件");
    },
    approveStatusFormat(row, column) {
      return this.getType(row, column);
    },
    // 上传文件，获取文件地址
    async uploadFile(eleFile) {
      // console.log(eleFile)
      const file = eleFile.file;
      let fileType = file.type;
      fileType = fileType.split("/");
      fileType = fileType[fileType.length - 1];
      // console.log(fileType)
      // 判断文件大小
      if (file.size > 10 * 1024 * 1024) {
        this.$message.error("文件大小不能超过10MB");
        return;
      }
      // 判断文件类型
      if (!this.acceptType.includes(fileType)) {
        this.$message.error("文件类型不正确");
        let uid = file.uid;
        let idx = this.$refs.uploadFile.uploadFiles.findIndex(
          (item) => item.id === uid
        );
        this.$refs.uploadFiles.splice(idx, 1);
        return;
      }
      const fd = new FormData();
      fd.append("file", file);
      try {
        const res = await service.post("/common/upload", fd, {
          headers: { "content-type": "multipart/form-data" },
        });
        if (res.code === 200) {
          // console.log(res)
          const obj = {
            name: file.name,
            url: res.url,
          };
          if (this.imageType.includes(fileType)) {
            this.imgUrl.push(res.url);
          }
          this.fileList.push(obj);
          this.quotedPrice.randomQuoteTable = this.fileList.map(
            (item) => item.url
          );
          // console.log(obj)
          this.$message({
            message: "上传成功",
            type: "success",
          });
        }
      } catch (e) {
        this.$message.error(e);
      }
    },
    closeDialog() {
      this.dialogVisible = false;
      this.remark = "";
    },
    //中标确认打印抽取表
    async handlePrint(row) {
      this.loadExtractArticl(row, true);
    },
     //中标确认打印比选表
       async handlePrints(row,text=1) {
      this.loadExtractArticl(row, true,text);
    },


    // 当表格的当前行发生变化的时候会触发该事件
    currentRowChange(currentRow) {
      this.currentRow = currentRow;
      this.quotationConfirm = [
        {
          name: "申请单位",
          detailInfo: currentRow.createBy,
          showTwo: true,
        },
        {
          name: "项目名称",
          detailInfo: currentRow.extractItem,
          showTwo: true,
        },
        {
          name: "建设地址",
          detailInfo: currentRow.extractAddress,
          showTwo: true,
        },
        {
          name: "建设周期",
          detailInfo: currentRow.extractPeriod,
          showTwo: true,
        },
        {
          name: "工程费用（万元）",
          detailInfo: currentRow.extractPrice,
          showTwo: true,
        },
        {
          name: "中介机构服务费（万元）",
          detailInfo: currentRow.maxPrice,
          showTwo: true,
        },
        {
          name: "抽  取  库",
          detailInfo: currentRow.unitTypeName,
          showTwo: true,
        },
        {
          name: "经办人",
          detailInfo: currentRow.extractCharge,
          showTwo: true,
        },
        {
          name: "联系电话",
          detailInfo: currentRow.extractPhone,
          showTwo: true,
        },
        {
          name: "业务类型",
          detailInfo: currentRow.extractBusinessType,
          showTwo: true,
        },
        {
          name: "是否需要驻场服务",
          detailInfo: currentRow.extractResident == 0 ? "是" : "否",
          showTwo: false,
        },
        {
          name: "驻场服务人数(至少)",
          detailInfo:
            currentRow.extractResident == 0
              ? currentRow.extractResidentNumber
              : "",
          showTwo: true,
        },
        {
          name: "完成时限",
          detailInfo:
            currentRow.extractResident == 0
              ? currentRow.extractLimitedTime
              : "",
          showTwo: true,
        },
        {
          name: "驻 场 要 求",
          detailInfo:
            currentRow.extractResident == 0
              ? currentRow.extractStationRequire
              : "",
          showTwo: false,
        },
        {
          name: "抽取单位数",
          detailInfo: currentRow.extractNumber,
          showTwo: false,
        },
        {
          name: "工程概况",
          detailInfo: currentRow.projectOverview,
          showTwo: false,
        },
        {
          name: "抽取要求",
          detailInfo: currentRow.extractBanReason, //不确定
          showTwo: false,
        },
      ];
      this.loadExtractArticle();
    },
    // 点击保存
    /*async submitquoted() {
			if(Array.isArray(this.quotedPrice.randomQuoteTable)){
			  this.quotedPrice.randomQuoteTable=this.quotedPrice.randomQuoteTable.join(',')
			}
			this.ruleForm.extractId = this.currentRow.extractId;
			this.quotedPrice.extractId = this.currentRow.extractId;
			this.ruleForm.extractApproveStatus = '6'
			const res = await approvalConfirm(this.quotedPrice)
      if(res.code === 200){
        this.$message.success(res.msg)
        this.uploadDialogVisible = false
      }
			this.quotedPrice.extractId = this.currentRow.extractId;
		},*/
    // 处理单位状态
    handleRandomBan(val) {
      switch (val) {
        case "0":
          return "正常";
        case "1":
          return "排除";
        case "2":
          return "中签";
        case "3":
          return "中标";
        case "4":
          return "未中标";
        case "5":
          return "废除报价";
      }
    },
    // 确认中标单位
    randomCompanyConfirm() {
      if (!this.randomUnitId) {
        return this.$message.error("请选择中标单位");
      }
      for (const i of this.companyInfo) {
        if (!i.bidamount && i.bidamount == "") {
          return this.$message.error("请完整填写报价情况");
        }
      }
      this.$confirm("确认提交吗?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          Promise.all([
            this.winningfirmsec(),
            this.winningfirm(),
            this.submitQuoted(),
          ]).then(() => {
            this.$message.success("操作成功");
            this.remark = "";
            this.dialogVisible = false;
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消提交",
          });
        });
    },
    // 中标确认1
    async submitQuoted() {
      this.companyInfo.forEach((item) => (item.randomBanRansom = this.remark));
      await approvalConfirm(this.companyInfo);
    },
    // 中标单位确认2
    async winningfirm() {
      const params = {};
      params.randomId = this.randomUnitId;
      params.extractId = this.currentDialogRow.extractId;
      await winningUnitConfirm(params);
    },
    // 中标单位确认3
    async winningfirmsec() {
      const params = {};
      params.extractApproveStatus = "7";
      params.extractId = this.currentDialogRow.extractId;
      await updateExtract(params);
    },
    async resultShow(row) {
      const extractId = row.extractId || this.ids;
      this.resultqueryParams.extractId = extractId.toString();
      await getRandomresult(this.resultqueryParams).then((response) => {
        this.items = response.data;
        if (this.items.length < 2) {
          this.rowspanList == 5;
        } else {
          this.rowspanList = this.items.length + 4;
        }
      });
      await getExtract(extractId).then((response) => {
        this.form = response.data;
        this.resultOpen = true;
        this.title = "";
      });
    },
    reback(row) {
      const extractIds = row.extractId || this.ids;
      var that = this;
      this.$confirm("是否重置当前抽签结果", "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(function () {
          delRandom(extractIds)
            .then((res) => {
              that.$message({
                message: res.msg,
                type: "success",
              });
              that.loadExtractList();
            })
            .catch((err) => {});
        })
        .catch(() => {
          this.loadExtractList();
        });
      this.ruleForm.extractPlace = "";
      this.ruleForm.extractUser = "";
    },
  },
  filters: {
    formatStatus(val) {
      switch (val) {
        case "0":
          return "未提交";
        case "1":
          return "申请中";
        case "2":
          return "审批通过";
        case "3":
          return "审批拒绝";
        case "4":
          return "已抽取";
        case "5":
          return "已发布";
        case "6":
          return "待确认";
        case "7":
          return "项目执行中";
        case "8":
          return "评价完成";
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.confirm-container {
  padding: 0 20px;
  .form-header {
    margin: 0;
    width: 100%;
    display: flex;
    align-items: center;
    border-bottom: unset;
    padding-top: 20px;
    .el-form-item {
      .search-btn {
        background-color: #1890ff;
      }
      .el-form-item__content {
        margin-left: 0 !important;
      }
    }
    .btns {
      margin-left: -50px;
    }
  }
  .pagination {
    display: flex;
    justify-content: flex-end;
    padding-top: 15px;
  }
  ::v-deep .el-dialog__title {
    font-weight: 600;
  }
  ::v-deep .el-dialog__body {
    padding: 0px 20px 30px 20px;
  }
  ::v-deep .el-upload-list {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    .el-upload-list__item {
      width: 50%;
    }
  }
  ::v-deep .el-upload {
    text-align: left;
  }
  ::v-deep .el-table .cell {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  ::v-deep .el-table .cell:hover {
    white-space: normal;
  }
  .container-wrap {
    > div {
      display: flex;
      align-items: baseline;
      width: 100%;
      > label {
        width: 130px;
        text-align: right;
      }
    }
  }
}
.commonWidth {
  width: 215px;
}
.image-wrap {
  display: flex;
  flex-wrap: wrap;
  margin-left: 60px;
  margin-top: 10px;
}

.uploadimg-wrap {
  position: relative;
  margin-right: 10px;
  .icon {
    cursor: pointer;
    position: absolute;
    top: -3px;
    right: 0px;
    font-size: 16px;
    color: red;
  }
}
.price-input {
  outline: none;
  width: 300px;
  height: 35px;
  border-radius: 5px;
  border: 1px solid #dcdfe6;
}
.outbid-info-wrap {
  padding-top: 30px;
}
.notify {
  color: rgb(255, 0, 0);
  text-align: center;
  margin-top: 5px;
}
.deduction-reason-wrap {
  display: flex;
  margin-left: 55px;
  > textarea {
    width: 80%;
  }
  label {
    flex: 0 0 auto;
    padding-right: 12px;
  }
}
.remain {
  width: calc(100% - 100px);
}
</style>
